package com.health.medicine.model.enums;

import lombok.Getter;

public enum TransportType {
    DRUG("药品", 1),
    DEVICE("医疗设备", 2),
    PATIENT("病人样本", 3),
    OTHER("其他", 4);

    @Getter
    private final String value;
    private final Integer code;

    TransportType(String value, Integer code) {
        this.value = value;
        this.code = code;
    }

    // 根据code获取value的方法
    public static String getValueByCode(Integer code) {
        for (TransportType type : TransportType.values()) {
            if (type.code.equals(code)) {
                return type.value;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    // 根据value获取code的方法
    public static Integer getCodeByValue(String value) {
        for (TransportType type : TransportType.values()) {
            if (type.value.equals(value)) {
                return type.code;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }
}
